package cn.com.open.itembank.sqlprovider;

import cn.com.open.itembank.utils.StringUtil;

import java.util.Map;

/**
 * Created by lucky on 2017/8/1.
 */
public class QuestionCategorySqlProvider {
    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(QuestionCategorySqlProvider.class);

    /**
     * 获取试题应用类别名称信息sql
     *
     * @param parameter the parameter
     * @return string string
     */
    public String getList(Map<String, Object> parameter) {
        String name = (String) parameter.get("name");
        Boolean enabled = (Boolean) parameter.get("enabled");

        StringBuilder sbSql = new StringBuilder();
        sbSql.append(" SELECT * FROM QuestionCategory");
        sbSql.append(" WHERE 1=1");
        if (!StringUtil.isEmpty(name)) {
            sbSql.append(" AND QuestionCategoryName LIKE '%" + name + "%'");
        }
        if (enabled) {
            sbSql.append(" AND Status = 1");
        }

        return sbSql.toString();
    }
}
